<template>
  <view class="bg-white">
    <scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y"
                 @scrolltolower="lower" >
      <uni-list :border="true" v-for="item in noticeList">
        <!-- 显示圆形头像 -->
<!--        <uni-list-chat :avatar-circle="true" title="uni-app"-->
<!--                       avatar="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png" note="您收到一条新的消息"-->
<!--                       time="2020-02-02 20:20" >-->
<!--        </uni-list-chat>-->
        <uni-list-chat :avatar-circle="true"
                       :title="item.noticeTitle"
                       avatar="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png"
                       :note="item.noticeContent"
                       :time="item.createTime" >
        </uni-list-chat>
      </uni-list>
    </scroll-view>
  </view>
</template>

<script>
import {getNotice, getNoticeList} from "../../api/system/user";

export default {
  name: "index",
  data() {
    return {
      scrollTop:0,
      noticeList:[]
    }
  },
  //生命周期函数
  mounted() {
    this.getList()
  },
  methods:{
    lower: function(e) {
      console.log(e)
    },
    // 获取列表的信息
    getList(){
      let that = this;
      getNoticeList({
        pageNum:1,
        pageSize:100
      }).then(res=>{
        console.log(res);
        that.noticeList = res.rows;
        //需要遍历 删除掉noticeContent字段中的html标签
        //简化下面的代码
        that.noticeList = that.noticeList.map(item=>{
          item.noticeContent = item.noticeContent.replace(/<[^>]+>/g,"");
          return item;
        })
      })
    },
  }
}
</script>

<style scoped>

</style>